package com.yida.system.api.factory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import com.yida.common.core.domain.R;
import com.yida.system.api.RemoteAreaService;
import com.yida.system.api.domain.SysArea;

/**
 * 短信服务降级处理
 * 
 * @author hmh
 * @date 2022/10/26
 */
@Component
public class RemoteAreaFallbackFactory implements FallbackFactory<RemoteAreaService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteAreaFallbackFactory.class);

    @Override
    public RemoteAreaService create(Throwable throwable) {
        log.error("地区服务调用失败:{}", throwable.getMessage());
        return new RemoteAreaService() {
            @Override
            public R<SysArea> getVoteAreaInfo(Long areaId, String source) {
                return R.fail("获取投票地区信息失败:{}" + throwable.getMessage());
            }
        };
    }
}
